<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/JavaScript" src="javascript.js"></script>
        <title>SCA - MANTER HORARIOS</title>
    </head>
    <body>

        <h1>MANTER HORARIOS</h1>

        <s:form action="Horarios" onsubmit="return verificaHorarios(this)">
            <s:hidden name="horarioSerial"></s:hidden>
            
            <s:textfield name="turma.codTurma" label="Código da Turma" value="%{turma.codTurma}" readonly="true"></s:textfield>
            <s:textfield name="turma.disciplina.nome" label="Disciplina" value="%{turma.disciplina.nome}" readonly="true"></s:textfield>
            <s:textfield name="turma.numVagas" label="Numero de Vagas" value="%{turma.numVagas}" readonly="true"></s:textfield>
            <s:textfield name="turma.professor.nome" label="Professor" value="%{turma.professor.nome}" readonly="true"></s:textfield>
            <s:textfield name="turma.numSala" label="Sala" value="%{turma.numSala}" readonly="true"></s:textfield>
            <s:textfield name="turma.ano" label="Ano" value="%{turma.ano}" readonly="true"></s:textfield>
            <s:textfield name="turma.semestre" label="Semestre" value="%{turma.semestre}" readonly="true"></s:textfield>

                <table border>
                    <tr>
                        <td>Horários</td>
                        <td>Segunda-Feira</td>
                        <td>Terça-Feira</td>
                        <td>Quarta-Feira</td>
                        <td>Quinta-Feira</td>
                        <td>Sexta-Feira</td>
                    </tr>
                <s:iterator value="horas">
                    <tr>
                        <td>${inicio} - ${fim}</td>
                        <s:iterator status="stat" value="%{diasSemana}">
                            <td>
                                <input type="checkbox" value="${stat.count + 1}-${inicio}" name="quadroHorario" 
                                       <s:iterator value="horarios">
                                           <s:if test="%{(#stat.count + 1) == diaSemana}">
                                               <s:if test="%{horarioInicio==inicio}">checked</s:if></s:if>
                                       </s:iterator>
                                       ></input>
                            </td>
                        </s:iterator>
                    </tr>

                </s:iterator>

            </table>
            <s:submit action="voltarHorarios" value="Voltar"></s:submit>
            <s:submit action="confirmarHorarios" value="Confimar"></s:submit>
        </s:form>
    </body>
    <script language="JavaScript">
        //<!---
        function verificaHorarios(form) {
            var horarioSerial = "";
            for (i = 0; i < form.quadroHorario.length; i++) {
                if (form.quadroHorario[i].checked) {
                    horarioSerial += form.quadroHorario[i].value + ",";
                }
            }
            form.horarioSerial.value = horarioSerial;

            return true;
        }
        //--->
    </script>
</html>